<html>
<head><meta charset="utf-8"><title>Discussion: Allow Release/Acquire ordering for CAS? · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Discussion.3A.20Allow.20Release.2FAcquire.20ordering.20for.20CAS.3F.html">Discussion: Allow Release/Acquire ordering for CAS?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="216122341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Discussion%3A%20Allow%20Release/Acquire%20ordering%20for%20CAS%3F/near/216122341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Oliver Giersch <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Discussion.3A.20Allow.20Release.2FAcquire.20ordering.20for.20CAS.3F.html#216122341">(Nov 09 2020 at 18:07)</a>:</h4>
<p>This is meant for discussion of the (now closed due to inactivity) PR <a href="https://github.com/rust-lang/rust/pull/74583">#74583</a>. The primary arguments for whether this ordering combination should be allowed are pretty exhaustively linked in the PR itself I believe. However, given that LLVM compiles this incorrectly on some platforms (relevant issue links can also be found in the PR) I would like to discuss how best to proceed with this PR. <br>
Note, that the PR consists of two parts: For one, it adds the necessary intrinsics and codegen code for generating the appropriate LLVM constructs for a CAS with release/acquire ordering, which is a purely internal change.<br>
Two, it amends the implementations in libcore for the <code>compare_exchange</code> and <code>compare_exchange_weak</code> methods on all atomic types. This is basically a <code>match (success, failure)</code> with a number of different combinations, which currently panics if release/acquire is used. This change is obviously outward-facing.<br>
From my perspective, there are 4 different alternatives:</p>
<ul>
<li>a) merge the additions as-is, meaning it will be possible to write code that, when compiled, does not respect the acquire ordering on success on ARM</li>
<li>b) refactor and merge only the internal intrinsics for now, and include the libcore changes at a later point (when and if LLVM fixes the codegen)</li>
<li>c) keep the PR closed and re-open/merge everything when and if LLVM codegen is fixed</li>
<li>d) do not merge at all and keep designating this combination as illegal (which would be an incorrect choice  in my estimation)</li>
</ul>



<a name="216123048"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Discussion%3A%20Allow%20Release/Acquire%20ordering%20for%20CAS%3F/near/216123048" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Discussion.3A.20Allow.20Release.2FAcquire.20ordering.20for.20CAS.3F.html#216123048">(Nov 09 2020 at 18:13)</a>:</h4>
<p>Definitely not (a).</p>



<a name="216123125"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Discussion%3A%20Allow%20Release/Acquire%20ordering%20for%20CAS%3F/near/216123125" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Discussion.3A.20Allow.20Release.2FAcquire.20ordering.20for.20CAS.3F.html#216123125">(Nov 09 2020 at 18:14)</a>:</h4>
<p>I would say c or d, depending on if we want to allow that ordering.</p>



<a name="216123162"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Discussion%3A%20Allow%20Release/Acquire%20ordering%20for%20CAS%3F/near/216123162" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Discussion.3A.20Allow.20Release.2FAcquire.20ordering.20for.20CAS.3F.html#216123162">(Nov 09 2020 at 18:14)</a>:</h4>
<p>That's just me, though.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>